{include file="header.html"}
<body class="gr">

<div class="navBar">
	<a class="left" href="javascript:history.back()"><i class="return"></i></a>
	<div class="titleView-x">我的消息</div>
</div>

<div class="message-index main-padding-top">
	<div class="pullRefresh">
		<ul class="tableView tableView-noMargin list">
			{foreach from=$data item=g}
			<li class="ge-bottom"><div class="scale11-left">{$g->content}<span class="scale10-left">{$g->add_time}</span></div></li>
			{foreachelse}
			<div class="norecord">没有任何记录</div>
			{/foreach}
		</ul>
	</div>
</div>g

{include file="footer.html"}
<script>
var offset = $('.pullRefresh .list > li').length;
function createHtml(g){
	var html = '<li class="ge-bottom"><div class="scale11-left">'+g.content+'<span class="scale10-left">'+g.add_time+'</span></div></li>';
	offset++;
	return html;
}
function setDelete(){
	$('.message-index .tableView').dragshow({
		title : '<i></i>',
		cls : 'delBtn',
		click : function(row){
			var _this = $(this);
			$.post('api.php?app=message&act=delete', { id:row.find('a').attr('mid') }, function(){
				var section = row.parent();
				if(section.find('li').length==1){
					location.href = location.href;
					return;
				}else{
					row.slideUp(200, function(){ row.remove() });
				}
				_this.delay(90).slideUp(200);
			});
		}
	});
}
$(function(){
	setDelete();
	$('body, .message-index').addClass('height-wrap');
	$('.pullRefresh').pullRefresh({
		header : true,
		footer : true,
		footerNoMoreText : '- END -',
		refresh : function(fn){
			var _this = this;
			offset = 0;
			$.getJSON('api.php?app=message&act=index', function(json){
				if(json.error!=0){ $.overloadError(json.msg);return }
				var html = '';
				if($.isArray(json.data))for(var i=0; i<json.data.length; i++)html += createHtml(json.data[i]);
				_this.find('.list').html(html);
				setDelete();
				fn();
			});
		},
		load : function(fn){
			var _this = this;
			$.getJSON('api.php?app=message&act=index', { offset:offset }, function(json){
				if(json.error!=0){ $.overloadError(json.msg);return }
				var html = '';
				if($.isArray(json.data))for(var i=0; i<json.data.length; i++)html += createHtml(json.data[i]);
				_this.find('.list').append(html);
				setDelete();
				fn();
			});
		}
	});
});
</script>